﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Web/BizWeb.Master" AutoEventWireup="true" CodeBehind="UserSelect.aspx.cs" Inherits="FrameWork.web.Web.Project.SelPage.UserSelect" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<script type="text/javascript">
    function GetRet() {
        var retval = SelectedObj();
        
        //变量：top.coverDivReturnValue是定义在DivCoverWindow.js上的top的传递变量.
        top.coverDivReturnValue = retval;
        //变量：top.callBackHandler是定义在DivCoverWindow.js上的top的传递变量
        if (top.callBackHandler) { var tmp = top.callBackHandler(); }
    }
    function SelectedObj() {
        var arr = [];
        var jqchecked = $("input:checked");
        //if (jqchecked.length == 0) { alert("请选择"); return false; }
        var UserID, UserName, UserEng, GroupName, RoleName, Email, Tel;
        var row;
        if ("True" === "<%=OnlyOne %>") {
            var tr = jqchecked.parent().parent();
            row = getRowData(tr);
            arr.push(row);
        } else {
            //todo
        }
        return arr;
    }
    function getRowData(tr) {
        var UserID, UserName, UserEng, GroupName, RoleName, Email, Tel;
        var checkedObj = $("input:checked",$("td[dname=userid]",tr));
        if(checkedObj.length >0)
        UserID = checkedObj.val();
        UserName = checkedObj.next().prop("innerText");
        UserEng = $("td[dname=ename]", tr).prop("innerText");
        GroupName = $("td[dname=groupname]", tr).prop("innerText");
        RoleName = $("td[dname=rolename]", tr).prop("innerText");
        Email = $("td[dname=email]", tr).prop("innerText");
        Tel = $("td[dname=email]", tr).prop("innerText");
        var obj = new userInfo(UserID, UserName, UserEng, GroupName, RoleName, Email, Tel);
        return obj;
    }
    function userInfo(UserID, UserName, UserEng, GroupName, RoleName, Email, Tel) {
        return { "UserID": UserID, "UserName": UserName, "UserEng": UserEng, "GroupName": GroupName, "RoleName": RoleName, "Email": Email, "Tel": Tel };
    }
    function validform() {
        if ($(":checked", $("#selecttable")).length == 0) {
            alert("请选择");
            return false;
        }

        return true;
    }
</script>
<table style="width:98%;margin:1px;padding:2px;">
    <tr><td>
    <table class="inputtbl" width="100%">
        <tr>
            <td>按<asp:DropDownList runat="server" ID="drpSelType" OnSelectedIndexChanged="drpSelType_SelectedIndexChanged" AutoPostBack="true">
                <asp:ListItem Text="姓名或拼音" Value="NameOrEng" Selected="True"></asp:ListItem>
                <asp:ListItem Text="部门" Value="Group"></asp:ListItem>
                <asp:ListItem Text="角色" Value="Role"></asp:ListItem>
            </asp:DropDownList>搜索:
            <asp:TextBox runat="server" ID="tbxKeyword" Width="80"></asp:TextBox>
            <asp:DropDownList runat="server" ID="drpRole" Visible="false"></asp:DropDownList>
             <asp:DropDownList runat="server" ID="drpGroup" Visible="false"></asp:DropDownList></td>
            <td><asp:Button runat="server" ID="btnQuery" Text="查询" class="btnblue1" /></td>
        </tr>
    </table>
    </td></tr>
    <tr><td class="secinfo">
     <table id="selecttable" border="0" cellpadding="0" cellspacing="0">
        <tr>
            <td class="caption">姓名</td>
            <td class="caption">账号</td>
            <td class="caption">部门</td>
            <td class="caption">角色</td>
            <td class="caption">邮件</td>
            <td class="caption">电话</td>
        </tr>
        <asp:Repeater runat="server" ID="Repeater1">
            <ItemTemplate>                
                <tr name="datarow">
                   <td dname="userid"><input type='<%=OnlyOne?"radio":"checkbox" %>' value='<%#Eval("UserID") %>' name="liUserID" id='rdUserID<%#Eval("UserID") %>'/><label for='rdUserID<%#Eval("UserID") %>'><%#Eval("U_CName") %></label></td>
                   <td dname="ename"><%#Eval("U_Ename") %></td>
                   <td dname="groupname"><%#Eval("GroupName")%></td>
                   <td dname="rolename"><%#Eval("RoleName")%></td>
                   <td dname="email"><%#Eval("U_Email") %></td>
                   <td dname="tel"><%#Eval("U_MobileNo") %></td>
                </tr>
            </ItemTemplate>        
        </asp:Repeater>              
    </table>   
    </td></tr>
    <tr><td> <FrameWorkWebControls:AspNetPager ID="Pager1" runat="server" OnPageChanged="Pager1_PageChanged" PageSize="10" CssClass="pgpanel">
    </FrameWorkWebControls:AspNetPager></td></tr>
    <tr><td align="center">  <input type="button" class="btnblue1" value="确定" onclick="if(validform()){GetRet();top.closeit();}"/></td></tr>
</table>
</asp:Content>
